package com.bjsxt;

import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.FileOutputStream;

public class DataOutputDemo {
    public static void main(String[] args) {
        DataOutputStream dos = null;
        try{
           dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("d:/data.txt")));
            dos.writeChar('a');
            dos.writeInt(10);
            dos.writeDouble(Math.random());
            dos.writeBoolean(true);
            dos.writeUTF("你好尚学堂");
            dos.flush();
        }catch(Exception e){
            e.printStackTrace();
        }finally{
            try{
                if(dos != null){
                    dos.close();
                }
            }catch(Exception e){
                e.printStackTrace();
            }
        }
    }
}
